//
//  ClothesCardView.swift
//  MyCloset
//
//  Created by 牟好好 on 2024/11/5.
//

import SwiftUI

struct ClothesCardView: View {
    var image: UIImage
    var title: String
    var onDelete: () -> Void
    
    var body: some View {
        ZStack(alignment: .topTrailing) {
            VStack {
                Image(uiImage: image)
                    .resizable()
                    .scaledToFit()
                
                HStack {
                    Text(title)
                        .font(.headline)
                        .multilineTextAlignment(.leading)
                        .padding(.horizontal, 5)
                }
                .foregroundStyle(.black)
                .padding(.bottom, 8)
            }
            
            Button(action: {
                onDelete()
            }, label: {
                Image(systemName: "trash")
                    .padding(.all, 5)
                    .foregroundStyle(.white)
                    .background(.black)
                    .clipShape(Circle())
            })
            .padding(.horizontal, boundsWidth * 0.025)
            .padding(.vertical, boundsWidth * 0.02)
        }
        .frame(width: boundsWidth * 0.4)
        .background(.white)
        .clipShape(RoundedRectangle(cornerRadius: 24))
        .shadow(radius: 8)
    }
}

// 推荐列表中的服装卡片视图
struct ClothesListCardView: View {
    var image: UIImage
    var title: String
    
    var body: some View {
        HStack {
            Image(uiImage: image)
                .resizable()
                .scaledToFit()
                .frame(maxWidth: boundsWidth * 0.3)
            
            Text(title)
                .padding(.trailing)
                .frame(maxWidth: boundsWidth * 0.5)
                .lineLimit(3)
                .font(.system(size: 18, weight: .bold))
        }
        .clipShape(RoundedRectangle(cornerRadius: 24))
        .background(Color("cardColor").cornerRadius(24))
        .shadow(radius: 8)
        .frame(maxWidth: .infinity, maxHeight: boundsHeight * 0.2)
    }
}

#Preview {
    ClothesCardView(image: UIImage(named: "testImg2") ?? UIImage(), title: "格纹，上装，鞋子，连衣裙") {}
}

#Preview {
    ClothesListCardView(image: UIImage(named: "testImg2") ?? UIImage(), title: "格纹，上装，鞋子，连衣裙")
}
